package org.bw.bookstore.book.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.bw.bookstore.book.service.impl.InventoryRulesServiceImpl;
import org.bw.bookstore.common.entity.TbReplenishmentRules;
import org.bw.bookstore.common.utils.ResponseResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import springfox.documentation.annotations.ApiIgnore;

/**
 *@program:wisdom_bookstore
 *@description:盘点规则控制层
 *@author:孙冬雪
 *@create:2020-10-22 09:50
 */
@RestController
@CrossOrigin
@Slf4j
@RequestMapping("/inventoryRules")
@Api(tags = "接口-盘点规则管理")
public class InventoryRulesController {

    @Autowired
    private InventoryRulesServiceImpl inventoryRulesService;

    /**
     * @Description 
     * TODO 孙冬雪--> makeInventoryRules 生成盘点规则
     * @Param [replenishmentRules] 
     * @Return com.bw.common.utils.ResponseResult
     * @Author 孙冬雪
     * @Date 2020/10/22 10:59
     **/
    @PostMapping("/makeInventoryRules")
    @ApiOperation(value="生成盘点规则", notes="生成盘点规则")
    @ApiImplicitParams(value = {
            @ApiImplicitParam(name = "startTime", value = "盘点开始时间",dataType = "Date",required = true),
            @ApiImplicitParam(name = "endTime", value = "盘点结束时间",dataType = "Date",required = true),
            @ApiImplicitParam(name = "timeInterval", value = "盘点规则时间间隔",dataType = "Integer",required = true),
            @ApiImplicitParam(name = "timeUnit", value = "间隔时间单位",dataType = "String",required = true),
            @ApiImplicitParam(name = "shopCode", value = "店铺",dataType = "String",required = true),
            @ApiImplicitParam(name = "staffMemberCode", value = "店长",dataType = "String",required = true)
    })
    public ResponseResult makeInventoryRules(@ApiIgnore TbReplenishmentRules replenishmentRules) {
        return inventoryRulesService.makeInventoryRules(replenishmentRules);
    }

    /**
     * @Description 
     * TODO 孙冬雪--> updateInventoryRules 修改盘点规则
     * @Param [replenishmentRules] 
     * @Return com.bw.common.utils.ResponseResult
     * @Author 孙冬雪
     * @Date 2020/10/22 10:59
     **/
    @PostMapping("/updateInventoryRules")
    @ApiOperation(value="修改盘点规则", notes="修改盘点规则")
    @ApiImplicitParams(value = {
            @ApiImplicitParam(name = "id", value = "盘点ID",dataType = "Integer",required = true),
            @ApiImplicitParam(name = "startTime", value = "盘点开始时间",dataType = "Date",required = true),
            @ApiImplicitParam(name = "endTime", value = "盘点结束时间",dataType = "Date",required = true),
            @ApiImplicitParam(name = "timeInterval", value = "盘点规则时间间隔",dataType = "Integer",required = true),
            @ApiImplicitParam(name = "timeUnit", value = "间隔时间单位",dataType = "String",required = true),
            @ApiImplicitParam(name = "shopCode", value = "店铺",dataType = "String",required = true),
            @ApiImplicitParam(name = "staffMemberCode", value = "店长",dataType = "String",required = true)
    })
    public ResponseResult updateInventoryRules(@ApiIgnore TbReplenishmentRules replenishmentRules) {
        return inventoryRulesService.updateInventoryRules(replenishmentRules);
    }
}
